#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>

int main()
{
  pid_t id = fork();

  if(id == 0)
  {
    char* const argv[] = 
    {
      (char*)"ls",
      (char*)"-l",
      (char*)"-a",
      NULL
    };
    execv("/usr/bin/ls", argv);
    printf("if replacement success, it should be print!\n");
    exit(100);
  }
  else if(id > 0)
  {
    int status = 0;
    pid_t rid = waitpid(id, &status, 0);
    if(rid > 0)
    {
      printf("father wait success! child exit code: %d\n", WEXITSTATUS(status));
    }
    printf("test end ...........\n");
  }

  return 0;
}
